<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
     // 1.  分别使用call，apply为obj添加name，age属性
//             function Test(){
//                 this.name = name;
//                 this.age = age;
//             }
//             obj = {}

//             function obj(name,age) {
//                 Test.call(this,name,age)
//             }
//              console.log(obj);

//              function obj(name,age) {
//                 Test.apply(this,name,age)
//             }
//              console.log(obj);

// // 2. 实现陈鹏买车，其中有sayHi方法，功能:打印'陈鹏买了一辆红色的2.0宝马车'
//             function Name(name) {
//                 this.name=name;
//             }

//             function Car(name,color,pailiang,brand) {
//                 Name.call(this,name,color,pailiang,brand)
//                 this.color=color;
//                 this.pailiang=pailiang;
//                 this.brand=brand;
//             }

//             var name=new Name();
//             Car.prototype=name;
//             var car=new Car('成鹏','红色','2.0t','宝马');
//             Car.prototype.name='成鹏';
//             Car.prototype.color='红色';
//             Car.prototype.pailiang='2.0t';
//             Car.prototype.brand='宝马';


//             console.log(this.name+'买了一辆颜色为'+this.color+'的排量为'+this.pailiang+'的'+this.brand);
//             console.log(car);


// // 3.父类Shape （属性有:name,length,width,方法有:Intro 我是XX形）
// // 子类： Circle(属性有:r)
// // 分别使用 原型链继承 构造函数继承 圣杯继承

        function Shape(name,length,width) {
            this.name=name;
            this.length=length;
            this.width=width;
            console.log('我是'+name+'形');
        }
        function Circle(r) {    
            this.r=r;
        }

        var Intor=new Shape('圆');
        Circle.prototype=Intor;
        console.log(Intor.name);

       
        function Shape(name,length,width) {
            this.name=name;
            this.length=length;
            this.width=width;
        }
        
        function Circle(name,length,width,r) {   
            Shape.call(this,name,length,width);
            this.r=r;
        }
        var circle=new Circle('我是正方形','10','20','5');
        console.log(circle);


       
        function Shape(name,length,width) {
            this.name=name;
            this.length=length;
            this.width=width;
        }
        function Circle(r) {    
            this.r=r;
        }

        function inherit(Target,Origin) {
            function F(){};
            var f=new F();
            Target.prototype=new F();
            Target.prototype.constuctor=Target;
            Target.prototype.uber=Origin.prototype;
        }
        Shape.prototype.name='呦西';
        function Shape(){};
        function Circle(){};

        inherit(Shape,Circle);

        var shape=new Shape();
        var circle=new Circle();
        console.log(shape.name);


// //爷爷拉二胡，粑粑弹琴
        function Grand(){};
        function Parent(){};
        Grand.prototype.tskill='拉二胡';
        var grand = new Grand();
        //Parent.prototype=grand; //删掉
        var parent =new Parent();
        Parent.prototype.tskill='弹琴';
        console.log('爷爷擅长'+grand.tskill);
        console.log('爸爸擅长'+parent.tskill);
    
    
    </script>
    
</body>
</html>